package echecs;

import java.util.List;
import outil.Action;
import outil.ActionChaine;
import outil.Si;
import outil.SiChaine;
import outil.TantQue;

public class ActionEchecs
        extends PredicatBase {

    static Action ParcourirDirections;
    static Action ConditionDeplacement;
    static Action DirectionCasRoiCavalier;
    static Action TantQueDirection;
    static Action SiArrOccupEtPiecesCoulOpp;
    static Action FouTourDameWhile;
    static Action SiPionArrVide;
    static Action SiPionAuDepart;
    static Action SiPion;
    static Action PionAction2;
    static Action TypePiece;

    public ActionEchecs() {

        ConditionDeplacement = Si.instance(PredicatBase.ArrVideOu_ArrOccupEtPiecesCoulOpp, ActionBase.NewCoups);
        DirectionCasRoiCavalier = TantQue.instance(PredicatBase.existeDirSuiv, ConditionDeplacement, ActionBase.DirSuivante);
        TantQueDirection = TantQue.instance(PredicatBase.ArrVide, ActionBase.NewCoups, ActionBase.DistSuivante);
        SiArrOccupEtPiecesCoulOpp = Si.instance(PredicatBase.ArrOccupEtPiecesCoulOpp, ActionBase.NewCoups);

        Action[] FouTourDameActionTab = {TantQueDirection, SiArrOccupEtPiecesCoulOpp, ActionBase.InitDist};
        FouTourDameWhile = TantQue.instance(PredicatBase.existeDirSuiv, ActionChaine.instance(FouTourDameActionTab), ActionBase.DirSuivante);

        SiPionArrVide = Si.instance(PredicatBase.ArrVide, ActionBase.NewCoups);

        Action[] PionAuDepartTab = {ActionBase.DistSuivante, SiPionArrVide};
        Action[] RoiCavalierActionTab = {ActionBase.InitDist, DirectionCasRoiCavalier};
        SiPionAuDepart = Si.instance(PredicatBase.estPionDep, ActionChaine.instance(PionAuDepartTab));

        Action[] PionCaseArriveeVideTab = {ActionBase.NewCoups, SiPionAuDepart};
        SiPion = Si.instance(PredicatBase.ArrVide, ActionChaine.instance(PionCaseArriveeVideTab));
        PionAction2 = TantQue.instance(PredicatBase.estFinDirPion, SiArrOccupEtPiecesCoulOpp, ActionBase.DirSuivante);
        Action[] PionActionTab = {ActionBase.InitIndex, SiPion, ActionBase.InitDir, ActionBase.DirSuivante, PionAction2};
        Action[] PieceActionTab = {FouTourDameWhile, ActionChaine.instance(PionActionTab), ActionChaine.instance(RoiCavalierActionTab)};
        TypePiece = SiChaine.instance(PieceType, PieceActionTab);
        Action[] ParcourirDirectionsTab = {ActionBase.NewArrayListCoups, ActionBase.InitIndex, TypePiece, ActionBase.AjoutCoupsListe};
        ParcourirDirections = ActionChaine.instance(ParcourirDirectionsTab);
    }

    public List<Coups> listeDesCoups() {
        return pListeCoups;
    }
}









